﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Smart.Data
{
    /// <summary>
    /// SqlCe 数据源
    /// </summary>
    public class SqlCeDataSource : DataSource
    {
        public SqlCeDataSource()
            : this(
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dbdemo.sdf")) { }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="model">路径</param>
        public SqlCeDataSource(string model)
        {
            Model = model;
            Provider = "System.Data.SqlServerCe";
            FormatString = "Data Source={0}";
        }

        public override string ToConnectionString()
        {
            if (string.IsNullOrEmpty(Password))
                return string.Format(FormatString, Model);
            return string.Format(FormatString, Model) + ";Password=" + Password + ";";
        }
    }
}
